<?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Exposure extends CI_Controller
{

	public function __construct()
	{
		parent::__construct();
		$this->load->library('HttpPost');
		$this->load->helper('url_helper');
		$this->load->library('SignatureClass');
		$this->load->model('Expose_Model');
		$this->load->library('session');
		$this->load->library('Vars');
	}
	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 *        http://example.com/index.php/welcome
	 *    - or -
	 *        http://example.com/index.php/welcome/index
	 *    - or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/user_guide/general/urls.html
	 */

	//获取开庭公告列表
//	public function exposurelist()
//	{
//		$data=array();
//		$data['ReallyName']='';
//		$data['ZXFY']='全部';
//		if(isset($_POST['pageno'])){
//			$data['pageno']=$_POST['pageno'];
//		}else{
//			$data['pageno']=1;
//		}
//		if(isset($_POST['pagesize'])){
//			$data['pagesize']=$_POST['pagesize'];
//		}else{
//			$data['pagesize']=15;
//		}
//
//		if(isset($_POST['ZXFY'])){
//			$data['ZXFY']=$_POST['ZXFY'];
//		}else{
//			$data['ZXFY']='全部';
//		}
//		if(isset($_POST['ReallyName'])){
//			$data['ReallyName']=$_POST['ReallyName'];
//		}
//		if(isset($_POST['CredentialsNumber'])){
//			$data['CredentialsNumber']=$_POST['CredentialsNumber'];
//		}
//		if(isset($_POST['AH'])){
//			$data['AH']=$_POST['AH'];
//		}
//		if(isset($_POST['StartLARQ'])){
//			$data['StartLARQ']=$_POST['StartLARQ'];
//		}
//		if(isset($_POST['EndLARQ'])){
//			$data['EndLARQ']=$_POST['EndLARQ'];
//		}
//		$url='http://www.zjsfgkw.cn/Execute/CreditPersonal';
//		$timeout = 40;
//		$response=$this->httppost->post($url,$data,$timeout);
//		$exposurelist=json_decode($response);
//		$query_state['ZXFY']=$data['ZXFY'];
//		$query_state['ReallyName']=$data['ReallyName'];
//		$articles=array('title'=>'曝光台');
//		$articles['query_state']=$query_state;
//		$articles['exposures']=$exposurelist;
//		if(empty($this->input->post('isAjax'))){
//			$this->load->view('head_sec',$articles);
//			$this->load->view('exposure_list',$articles);
//			$this->load->view('foot_sec',$articles);
//		}else{
//			header('content-type:application:json;charset=utf8');
//			header('Access-Control-Allow-Origin:*');
//			header('Access-Control-Allow-Methods:POST');
//			header('Access-Control-Allow-Headers:x-requested-with,content-type');
//			$result = array();
//			$result['isSuccess'] = true;
//			$result['errorMessage'] = '';
//			$result['data'] = $exposurelist;
//			echo json_encode($result, JSON_UNESCAPED_UNICODE);
//		}
//	}

	public function exposurelist()
	{
		if(empty($this->input->post('isAjax'))){
			$param=$this->input->post('param');
			$exposures=$this->Expose_Model->get_expose($param);
			$totalcount=$this->Expose_Model->get_all_expose_count();
			$articles=array();
			$articles['exposures']=$exposures;
			$articles['title']='曝光台';
			$articles['totalcount']=$totalcount;
			$this->load->view('head_sec',$articles);
			$this->load->view('exposure_list',$articles);
			$this->load->view('foot_sec',$articles);
		}else{
			$pagenum=$this->input->post('pagenum');
			$pagesize=$this->input->post('pagesize');
			$startrow=$pagenum*$pagesize;
			$endrow=($pagenum+1)*$pagesize;
			$exposures=$this->Expose_Model->get_expose_by_page($pagesize,$endrow);
			header('content-type:application:json;charset=utf8');
			header('Access-Control-Allow-Origin:*');
			header('Access-Control-Allow-Methods:POST');
			header('Access-Control-Allow-Headers:x-requested-with,content-type');
			$result = array();
			$result['isSuccess'] = true;
			$result['errorMessage'] = '';
			$result['data'] = $exposures;
			echo json_encode($result, JSON_UNESCAPED_UNICODE);
		}
	}

	public  function detail($id){
		//$uri=$this->uri->uri_string();
		$uri= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
		$array=array('uri'=>$uri);
		$this->session->set_userdata($array);
		$data=$this->signatureclass->generate_signature();
		$varriable=$this->vars->get_constants();
		$expose=$this->Expose_Model->get_expose_by_id($id);
		$data['APPID']=$varriable['APPID'];
		$data['title']='执行详情';
		$data['expose']=$expose;
		$this->load->view('head_sec',$data);
		$this->load->view('exposure_detail',$data);
		$this->load->view('foot_sec',$data);
	}
}


